/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.aurelius;

import org.apache.wicket.IPageFactory;
import org.apache.wicket.Page;
import org.apache.wicket.Session;
import org.apache.wicket.devutils.debugbar.DebugBar;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.page.IManageablePage;
import org.apache.wicket.page.IPageManager;
import org.apache.wicket.request.mapper.parameter.PageParameters;

/**
 *
 * @author Lukasz
 */
public class SomeWicketPage extends WebPage {

    /**
     * Cos.
     */
    private static final long serialVersionUID = 1L;
    private String version;

    /**
     * Hippie.
     *
     * @param parameters some params.
     */
    public SomeWicketPage(final PageParameters parameters) {
        super();
//        add(new Link("devDebug") {
//
//            @Override
//            public void onClick() {
//
//                setResponsePage(InspectorPage.class);
//            }
//        });
        add(new DebugBar("debugBar"));
        IPageManager pageManager = Session.get().getPageManager();
        IPageFactory pageFactory = Session.get().getPageFactory();

        StringBuilder stringBuilder = new StringBuilder();

        int counter = 0;
        while (true) {
            IManageablePage page = pageManager.getPage(counter);
            if (page == null) {
                break;
            }
            Page castedPage = (Page) page;

            stringBuilder.append(page.getPageId() + " - " + castedPage.toString() + " --- " + castedPage.getClass() );

            counter++;
        }
        add(new Label("versionaaa",  stringBuilder.toString()));

        add(new Link("linkToHomePage") {

            @Override
            public void onClick() {
                setResponsePage(HomePage.class);
            }
        });
    }
}
